<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>资管客户还款管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
    <form id="insCstSettle_form">
        <div class="fieldset1 tabel_col tabel_col_1 clearFix">
            <div class="fieldBox col_100">
                <div class="label">资方支付表号</div>
                <div class="field">
                    ${insCstRepaySettleVO.paySchNo}
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">提前还款本金</div>
                <div class="field">
                    ${insCstRepaySettleVO.repayCapAmt}
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">提前还款利息</div>
                <div class="field">
                    ${insCstRepaySettleVO.repayIntrAmt}
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">提前还款总金额</div>
                <div class="field">
                    ${insCstRepaySettleVO.repayTtlAmt}
                </div>
            </div>
            <div class="fieldBox col_100" id="errorMsgDiv" style="display:none;">
                <div class="label">错误描述</div>
                <div class="field">
                    <span class="requiredSymbol" id="errorMsg">${errorMsg}</span>
                </div>
            </div>
        </div>
    </form>
    <script>
        var form=null;
        $(function() {
            form = $("#insCstSettle_form").ligerForm({
                validate: true
            });


            if("${errorFlag}"=="1"){
                $("#errorMsgDiv").show();
            }

            var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
            //按钮在页面外的Dialog里，给Dialog绑定事件 （onOk 和 onCancel）
            frameElement.dialog.onOk = function () {
                if("${errorFlag}"=="1"){
                    $.ligerDialog.SQalert({content: "查询三方试算结果失败，不能操作提前还款", SQ_type: "error", SQ_showButtons: true});
                    return false;
                }
                if (!form.valid()) {
                    $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                    return false; //验证不通过，不执行以下代码
                }
                frameElement.dialog.disabledBtns();
                frameElement.dialog.mask();
                var insCode="${insCstRepaySettleVO.insCode}";
                var _url= '<%=path%>/repay/insCstRepaySettle/repayOrsettle.do';
                var data = {"id":"${insCstRepaySettleVO.id}","prjId":"${insCstRepaySettleVO.prjId}","insId":"${insCstRepaySettleVO.insId}","type":"settle","insCode":"${insCstRepaySettleVO.insCode}"};
                var wait_dialog;

                $.ligerDialog.confirm("是否确定提前还款？", function (flag) {
                    if (flag == false) return;
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: data,
                        url: _url,
                        beforeSend: function () {
                            wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                        },
                        success: function (msg) {
                            wait_dialog.close();
                            if (msg.success == 1) {
                                $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                                frameElement.dialog.close();
                            } else {
                                $.ligerDialog.SQalert({content: msg.info, SQ_type: "error", SQ_showButtons: true});
                            }
                        }
                    });
                });
            }

            frameElement.dialog.onCancel = function () {
                frameElement.dialog.hide();
            };
        });
    </script>
</body>
</html>
